--Redzone RPG
--By Kylegar


include("sharedstuff.lua")

local Item = {}


function Item:Init()
Item.Classname = "rz_HealthPack"
Item.Printname = "Health Pack"
Item.Owner = nil
Item.OnGround = true
Item.IsItem = true
Item.Ammount = 1
Item.Model = [[models\props_c17\oildrum001_explosive.mdl]]

end

function rzItem:GetClassName()
	return self.Classname
end

function rzItem:GetName()
	return self.Printname
end


function rzItem:GetItemID()
	return self.ItemID
end

function rzItem:SetItemOwner(ply)
	self.Owner = ply
end

function rzItem:GetOwner()
	return self.Owner
end

function rzItem:IsOnGround()
	return self.OnGround
end

function rzItem:SetModel(modelpath)
	self.Model = modelpath
end


function rzItem:IsValid()
	if !(self.IsItem) then return false end
	
	if (table.HasValue(ItemsActive, self)) then
		for k , v in pairs(ItemsActive) do
			if (table.HasValue(v , self.ItemID)) then
				return true
			end
		end
	end			
end

function rzItem:Remove()
	if(self.Owner && self.Owner:IsPlayer()) then
		if(self.Ammount > 1) then
			self.Ammount = self.Ammount - 1
		else
			self.Owner:RemoveFromInv(self)
		end
		return
	end
	if(table.HasValue(ItemsActive, self)) then
		for k,v in pairs(ItemsActive) do
			if(table.HasValue(v, self.ItemID)) then
				table.remove(ItemsActive , k)
				return
			end
		end
	end
	
end 

function Item:OnUse()
	if!(self.Owner)then return end
	self.Owner:SetHealth(self.Owner:Health() + 50)
	self:Remove()	
end




Item:Init()

Item.OnUse = Item:OnUse()
Msg("ItemSet, Registering\n")
rzItem.RegisterItem(Item)